﻿using System.ComponentModel;
using DeepEarth.Map.Core;
using System;

namespace DeepEarth.Toolkit.Controls.Automation
{
    public class Transition
    {
        #region Properties
        MapViewLite InitialView { get; set; }

        MapViewLite TargetView { get; set; }

        TimeSpan TransitionTime {get; set;}

        public double TotalFrames { get; set; }
        
        #endregion

        public Transition(MapViewLite initial, MapViewLite target, TimeSpan duration, double frameRate)
        {
            InitialView = initial;
            TargetView = target;
            TransitionTime = duration;

            TotalFrames = duration.TotalSeconds * frameRate;
        }

        DefaultDisplacement displacementCalculator;
        public MapViewLite GetView(double proportion)
        {
            if (displacementCalculator == null
                || displacementCalculator.TargetView != TargetView
                || displacementCalculator.InitialView != InitialView)
                displacementCalculator = new DefaultDisplacement(InitialView, TargetView);

            return displacementCalculator.CalculatePosition(proportion);
        }

    }
}